<?php
/**
 * Created by PhpStorm.
 * User: MSQ
 * Date: 2021/9/27
 * Time: 16:54
 */

namespace App\Handler\Http;


use EasySwoole\Http\Request;
use EasySwoole\Http\Response;

class ExceptionHandler
{
    public static function handle(\Throwable $exception, Request $request, Response $response)
    {
        var_dump($exception->getTraceAsString());

        $response->withHeader('Content-Type', 'application/json;charset=utf-8');
        $response->write(json_encode([
            'code' => 422,
            'msg' => $exception->getMessage(),
        ]));
    }
}
